<template>
  <div class="app-container">
    <el-form :inline="true" :model="form" ref="form-inline">
      <el-form-item label="企业名称" prop="entName" >
          <el-input v-model="form.entName" placeholder="企业名称"></el-input>
      </el-form-item>
      <el-form-item  label="企业信用代码" prop="entUniId" >
          <el-input  style="width: 250px;" v-model="form.entUniId" placeholder="企业信用代码"></el-input>
      </el-form-item>
      <el-form-item>
          <el-button type="primary"  @click="search">查询 </el-button>
      </el-form-item>
    </el-form>
    <Table 
          class="businessFormTable"
          ref="Table" 
          :tableData="tableData" 
          :tableHeadData="tableHeadData" 
          v-loading="tableLoading"
          @getList="getTableList" 
          :total="total"
          @linkTo="linkTo"
      />
  </div>
</template>

<script>
import Table from '@/components/table/table.vue';
import { JueceCommon } from './juece.common'
import { batchList } from '@/api/user'
export default {
  components:{
    Table
  },
  data() {
    return {
      form:{
        entName:null,
        entUniId:null
      },
      tableData:[],
      tableHeadData:[],
      tableLoading:false,
      currentPageParams:{
          'pageNum': 1,
          'pageSize': 10
      },
      total:0
    }
  },
  created(){
    this.jueceCommon = new JueceCommon(this);
  },
  mounted(){
    this.search()
  },
  methods:{
    async getTableList({ pageSize = 10, pageNum = 1 } = this.currentPageParams) {
      this.tableLoading = true;
      this.form.entName == '' ? this.form.entName = null : '';
      this.form.entUniId == '' ? this.form.entUniId = null : '';
      const params = {
        rows:pageSize,
        page:pageNum,
        batch:this.form
      };
      this.currentPageParams = {
        pageNum,
        pageSize
      }
      //console.log('getTableList', pageSize,pageNum)
      //return
      const res = await batchList(params);
      //console.log('res',res);
      const { rows,total } = res.data;
      this.total = total;
      this.tableData = this.jueceCommon.fomatData_EI(rows);
      this.tableHeadData = this.jueceCommon.tableHead_EI(rows[0],this);
      this.tableLoading = false;
      //this.$nextTick(_ => this.$refs.Table.doLayout()); //重绘表格 数据变动后表格头错乱
    },
    search(){
       // console.log('onSubmit',this.form)
       this.getTableList(this.currentPageParams)
    },
    linkTo(row,col){
      console.log('row',row)
      this.$router.push({
        path:'/enterpriseSearch',
          query: {
            batchNo:row.no
          },
      })
    }
  }
}
</script>

<style scoped lang="scss">
 ::v-deep .pagination {
  .el-pagination{
    text-align: center;
  }
 }
</style>